Skip to content

fix: address PR review comments#1912

Open
RustyCoderX wants to merge 2 commits into
kagent-dev:mainfrom
RustyCoderX:fix/cluster-domain-support-updated
Open

fix: address PR review comments#1912
RustyCoderX wants to merge 2 commits into
kagent-dev:mainfrom
RustyCoderX:fix/cluster-domain-support-updated

Conversation

@RustyCoderX
Copy link
Copy Markdown

Addressed the review feedback by wiring clusterDomain into the actual runtime flow instead of leaving it unused, tightening internal .svc URL detection to avoid matching external domains incorrectly, fixing the related comments/documentation, restoring the Grafana MCP default service URL, and adding regression tests for cluster-domain-aware URL handling. Also propagated the config through the HTTP server and translator paths so custom cluster domains are consistently supported end-to-end

Signed-off-by: Ayush <ayumane63@gmail.com>
Copilot AI review requested due to automatic review settings May 25, 2026 06:59
@github-actions github-actions Bot added the bug Something isn't working label May 25, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds support for configurable Kubernetes cluster DNS domains and updates default Grafana MCP URLs to use fully-qualified in-cluster service DNS, improving internal URL detection and security.

Changes:

  • Update Helm default Grafana API URL to http://grafana.<ns>.svc.cluster.local:3000/api.
  • Introduce --cluster-domain config/flag and plumb it through the HTTP server/handlers into the agent translator.
  • Harden internal Kubernetes URL detection logic and add unit tests for cluster-domain handling.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
helm/tools/grafana-mcp/values.yaml Updates default Grafana API URL to in-cluster FQDN with scheme.
helm/kagent/values.yaml Aligns kagent chart’s grafana-mcp URL default with in-cluster FQDN.
go/core/pkg/app/app.go Adds ClusterDomain config/flag and passes it into the translator.
go/core/internal/httpserver/server.go Extends server config and handler construction to include ClusterDomain.
go/core/internal/httpserver/handlers/handlers.go Stores ClusterDomain in handler base and extends NewHandlers signature.
go/core/internal/httpserver/handlers/agents.go Passes ClusterDomain to the agent translator.
go/core/internal/controller/translator/agent/cluster_domain_test.go Adds tests covering internal URL detection across cluster domains.
go/core/internal/controller/translator/agent/adk_api_translator.go Adds ClusterDomain support, improves internal URL validation, and refactors namespace checks.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +1021 to +1034
func (a *adkApiTranslator) namespaceExistsOrWatched(ctx context.Context, potentialNamespace string) bool {
ns := &corev1.Namespace{}
err := a.kube.Get(ctx, types.NamespacedName{Name: potentialNamespace}, ns)
if err == nil {
return true
}
if (apierrors.IsForbidden(err) || apierrors.IsUnauthorized(err)) && len(a.watchedNamespaces) > 0 {
return slices.Contains(a.watchedNamespaces, potentialNamespace)
}
return false
}

return false
}
Comment on lines +993 to +995
if validation.IsDNS1123Label(parts[0]) != nil || validation.IsDNS1123Label(parts[1]) != nil {
return false
}
Comment on lines +17 to +18
scheme := k8sscheme.Scheme
require.NoError(t, v1alpha2.AddToScheme(scheme))
- Remove stray return/brace in adk_api_translator.go
- Use len(validation.IsDNS1123Label(...)) > 0 checks
- Use fresh scheme in cluster_domain_test.go

Signed-off-by: Automated Fix <auto-fix@example.com>
Signed-off-by: Ayush <ayumane63@gmail.com>
clusterDomain = "cluster.local"
}
a.clusterDomain = clusterDomain
return a
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: prefer using a != nil instead for slightly better readability

Suggested change
return a
if a != nil {
clusterDomain = strings.TrimSpace(clusterDomain)
if clusterDomain == "" {
clusterDomain = "cluster.local"
}
a.clusterDomain = clusterDomain
}
return a

Comment on lines -961 to -962
// Extract namespace from hostname pattern: {name}.{namespace}
// Examples: test-mcp-server.kagent -> namespace is "kagent"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: can we keep this comment? this seems to still be relevant so it would be good context.

return a.namespaceExistsOrWatched(ctx, potentialNamespace)
}

if len(parts) == 3 && parts[2] == "svc" {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: would be helpful to add a comment that this conditional specifically addressesing a hostname using the grafana.kagent.svc construction

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants